Fix paint not working with OpenRouter provider (#513)#558
Open
khasinski wants to merge 1 commit intocrmne:mainfrom
Open
Fix paint not working with OpenRouter provider (#513)#558khasinski wants to merge 1 commit intocrmne:mainfrom
khasinski wants to merge 1 commit intocrmne:mainfrom
Conversation
9502ce0 to
b0963d3
Compare
|
Please, maintainers, take a look here, we need this! :) |
OpenRouter uses the chat completions endpoint for image generation instead of a dedicated /images/generations endpoint. This commit adds an OpenRouter::Images module that: - Routes image generation requests to chat/completions - Formats the payload with modalities: ["image", "text"] - Parses the response from choices[0].message.images[] - Handles both base64 data URLs and regular URLs
b0963d3 to
49a2912
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
OpenRouter uses the chat completions endpoint for image generation instead of a dedicated /images/generations endpoint. This commit adds an OpenRouter::Images module that:
What this does
When using
RubyLLM.paintwith OpenRouter, requests were being sent tohttps://openrouter.ai/api/v1/images/generations, which doesn't exist. OpenRouter returns a405 Method Not Allowederror.OpenRouter implements image generation via the chat completions endpoint (
/chat/completions) with modalities:["image", "text"], not through a dedicated images endpoint.This PR adds an
OpenRouter::Imagesmodule that overrides the inheritedOpenAI::Imagesbehavior to:chat/completionsinstead ofimages/generations["image", "text"]choices[0].message.images[]as base64 data URLsTested with
google/gemini-2.5-flash-image-previewvia OpenRouter.Type of change
Scope check
Quality check
overcommit --installand all hooks passbundle exec rake vcr:record[provider_name]bundle exec rspecmodels.json,aliases.json)API changes
Related issues
Fixes #513